package com.zy.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zy.business.domain.TbHoliday;
import com.zy.common.utils.HolidayUtil;
import com.zy.business.mapper.HolidayMapper;
import com.zy.business.service.HolidayService;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @description:工作日管理 服务层实现
 * @author: whf
 * @create: 2022-07-30 11:19
 **/
@Service
public class HolidayServiceImpl extends ServiceImpl<HolidayMapper, TbHoliday> implements HolidayService {

    @Override
    public Integer createHoliday(Date date){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        int flag = HolidayUtil.request(sdf.format(date));
        TbHoliday holiday = new TbHoliday();
        holiday.setDate(date);
        holiday.setType(flag);
        this.save(holiday);
        return holiday.getType();
    }
}
